<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../../css/index.css" type="text/css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/detailstyle.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/ShopShow.css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
<title>Insert title here</title>
</head>
<body>
		<header id="header">
			<div class="header-box">
				<ul class="header-left">
				</ul>
				<ul class="header-right">
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/user/userLogin.jsp">您好，请登录</a> <a href="${pageContext.request.contextPath}/jsp/user/userRegister.jsp"  class="red">免费注册</a></li> 
					<li class="shu"></li>
					<li class="denglu"><a href="#">我的订单</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/showFavorite?userId=${sessionScope.user.userId}">我的收藏夹</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/getUsers?userId=${sessionScope.user.userId}">个人中心</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/shop/ShopLogin.jsp">卖家中心</a></li>
					<li class="denglu"><a href="${pageContext.request.contextPath}/jsp/login/login.jsp">管理员中心</a></li>
				</ul>
			</div>
		</header>
			<div class="logo"><a href="${pageContext.request.contextPath}/index.jsp"><img width="100" height= "80" src="./images/logo.png"></a></div>
<div class="jdm-toolbar-wrap J-wrap">                
			<div class="jdm-toolbar J-toolbar">                    
				 <div class="jdm-toolbar-panels J-panel">                                             
				</div>                                       
				<div class="jdm-toolbar-tabs J-tab">  
					<div data-type="bar" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-cart">                                
						<i class="tab-ico"></i><a href="${pageContext.request.contextPath}/Carts?userId=${sessionScope.user.userId}">                              <em class="tab-text">购物车                                
						</em>   </a>                                                 
					</div>   
					<div class="J-trigger jdm-toolbar-tab jdm-tbar-tab-message" data-name="message">
					<i class="tab-ico"></i><a href="${pageContext.request.contextPath}/showFavorite?userId=${sessionScope.user.userId}">                                 
					<em class="tab-text">      收藏夹                               
					</em></a>                                               
				</div>                     
			</div>                     
			<div class="jdm-toolbar-footer">                        
				<div data-type="link" id="#top" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-top">                                
					<a href="#" clstag="h|keycount|cebianlan_h|top">                                
						<i class="tab-ico"></i>                                <em class="tab-text">顶部</em>                                
					</a>                         
				</div>                        
				<div data-type="link" class="J-trigger jdm-toolbar-tab jdm-tbar-tab-feedback">                                 
					<a href="http://surveys.jd.com/index.php?r=survey/index/sid/889711/newtest/Y/lang/zh-Hans" target="_blank" clstag="h|keycount|cebianlan_h|feedback">                                    
						<i class="tab-ico"></i>                                    
						<em class="tab-text">反馈</em>                                
					</a>                        
				</div>                        
			</div>                    
			<div class="jdm-toolbar-mini">                    
			</div>                
		</div>                
		<div id="J-toolbar-load-hook" clstag="h|keycount|cebianlan_h|load"></div>            
	</div>
	
<!--主体部分-->
<section class="center">
    <!--End Menu End-->
    <div class="i_bg">
        <div class="postion">
            <span class="fl"><i>${goods.goodsName}</i></span>
        </div>
        <div class="clear" >
            <!-- 详情页面左侧图片 -->
            <div id="tsShopContainer">
                <div id="tsImgS">
                    <a href="img/p_big.jpg" class="MagicZoom">
                        <img src="${pageContext.request.contextPath}/images/${goods.goodsPhoto}" width="390" height="390"/>
                    </a>
                </div>
            </div>
            <!-- 右侧商品信息 -->
            <div class="pro_des" style="margin-top: 5px">
                <div class="des_name">
                    <p>${goods.goodsName}</p>
                </div>
                <div class="des_price" style="margin-top: 5px">
                	本店价格：<b>¥${goods.goodsPrice}</b><br/>
                </div>
                <div class="des_choice" style="margin-top: -30px">
                    <span class="fl">类型：${goods.goodsType} | 产地：${goods.goodsAddress} | 口味：${goods.goodsTaste} | 净含量：${goods.goodsWeigth}</span>
                </div>
                <div class="des_choice" style="margin-top: 5px;">
                    <div><span class="fl">库存：${goods.goodsStock}</span></div>
                    <div style="margin-left:100px">
	                    <c:if test="${goods.goodsState == 1}"><td align="center">正常售卖</td></c:if>
						<c:if test="${goods.goodsState == 0}"><td align="center">已下架</td></c:if>
					</div>
                </div>
                <div class="des_share" style="margin-top: 10px">
                    <div class="d_sh">
                      	  分享
                        <div class="d_sh_bg">
                            <a href="#"><img src="${pageContext.request.contextPath}/img/sh_1.gif"/></a>
                            <a href="#"><img src="${pageContext.request.contextPath}/img/sh_2.gif"/></a>
                            <a href="#"><img src="${pageContext.request.contextPath}/img/sh_3.gif"/></a>
                            <a href="#"><img src="${pageContext.request.contextPath}/img/sh_4.gif"/></a>
                            <a href="#"><img src="${pageContext.request.contextPath}/img/sh_5.gif"/></a>
                        </div>
                    </div>
                    <div class="d_care" onclick="favorite(${goods.goodsId},${sessionScope.user.userId })"><a>加入收藏夹</a></div>
                </div>
                <div class="des_join" style="margin-top: 5px">
                    <div class="j_nums">
                        <input type="text" value="1" name="sum" class="n_ipt" id="count"/>
                        <input type="button" value="" class="n_btn_1" onclick="inrs()"/>
                        <input type="button" value="" class="n_btn_2" onclick="ders()"/>
                    </div>
                    <div><span class="fl"><a><img src="${pageContext.request.contextPath}/img/j_car.png" onclick="addCart(${goods.goodsId},${sessionScope.user.userId})"/></a></span></div>
                </div>
                <div style="margin-top: 20px">
                <span class="fl"><button style="width:200px;height:45px;font-family:'Microsoft yahei';font-size:20px;background:#f60;color:#fff;border:none;" onclick="goOrder(${goods.goodsId},${sessionScope.user.userId })">立即购买</button></span></div>
            </div>
        </div>

        <div class="content">
            <div class="l_list">
                <!--商品属性-->
                <div class="des_border">
                    <div class="des_tit">
                        <ul>
                            <li class="current"><a href="#p_attribute">商品属性</a></li>
                             <li><a href="#p_details">商家信息</a></li>
                            <li><a href="#p_comment">商品评论</a></li>
                        </ul>
                    </div>
                    <div class="des_con" id="p_attribute">
                        <table border="0" align="center" style="width:100%; margin:10px auto;"
                               cellspacing="0" cellpadding="0">
                            <tr>
                                <td>商品编号：${goods.goodsId}</td>
                                <td>商品名称：${goods.goodsName}</td>
                                <td>商品类型： ${goods.goodsType}  口味：${goods.goodsTaste}</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                            	<td>商品产地：${goods.goodsAddress}</td>
                                <td>商品毛重：${goods.goodsWeigth}</td>
                                <td>食用方法：${goods.goodsDirection}</td>
                                <td>&nbsp;</td>
                            </tr>
                            <tr>
                                <td>生产日期：<fmt:formatDate value="${goods.goodsDate }" pattern="yyyy-MM-dd"/></td>
                                <td>保质期：${goods.goodsLife}</td>
                                <td>储存方法：${goods.goodsStore}</td>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                    </div>
                </div>	
                <!--商家信息-->
                <div class="des_border" id="p_details">
                    <div class="des_t">商家信息</div>
                    <div class="des_con" id="showShop"></div>
                </div>
                <!--商品评论-->
                <div class="des_border" id="p_comment">
                    <div class="des_t">商品评论</div>
                    <table border="0" class="jud_list" style="width:100%; margin-top:30px;" cellspacing="0" cellpadding="0">
 						<div id="showEval"></div>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<div class="lazy-fn lazy-fn-done" id="lazy-footer">        
		<div id="service-2014">
	<div class="slogen">
		 <img src="../../images/duo.png" alt="">
	</div>
	<div class="w">
		<dl class="fore1">
			<dt>购物指南</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">购物流程</a></div>
				<div><a rel="nofollow" target="_blank" href="#">会员介绍</a></div>
				<div><a rel="nofollow" target="_blank" href="#">生活旅行/团购</a></div>
				<div><a rel="nofollow" target="_blank" href="#">常见问题</a></div>
				<div><a rel="nofollow" target="_blank" href="#">大家电</a></div>
				<div><a rel="nofollow" target="_blank" href="#">联系客服</a></div>
			</dd>
		</dl>
		<dl class="fore2">		
			<dt>配送方式</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">上门自提</a></div>
				<div><a rel="nofollow" target="_blank" href="#">211限时达</a></div>
				<div><a rel="nofollow" target="_blank" href="#">配送服务查询</a></div>
				<div><a rel="nofollow" target="_blank" href="#">配送费收取标准</a></div>
				<div><a target="_blank" href="#">海外配送</a></div>
			</dd>
		</dl>
		<dl class="fore3">
			<dt>支付方式</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">货到付款</a></div>
				<div><a rel="nofollow" target="_blank" href="#">在线支付</a></div>
				<div><a rel="nofollow" target="_blank" href="#">分期付款</a></div>
				<div><a rel="nofollow" target="_blank" href="#">邮局汇款</a></div>
				<div><a rel="nofollow" target="_blank" href="#">公司转账</a></div>
			</dd>
		</dl>
		<dl class="fore4">		
			<dt>售后服务</dt>
			<dd>
				<div><a rel="nofollow" target="_blank" href="#">售后政策</a></div>
				<div><a rel="nofollow" target="_blank" href="#">价格保护</a></div>
				<div><a rel="nofollow" target="_blank" href="#">退款说明</a></div>
				<div><a rel="nofollow" target="_blank" href="#">返修/退换货</a></div>
				<div><a rel="nofollow" target="_blank" href="#">取消订单</a></div>
			</dd>
		</dl>
		<dl class="fore5">
			<dt>特色服务</dt>
			<dd>		
				<div><a target="_blank" href="#">夺宝岛</a></div>
				<div><a target="_blank" href="#">DIY装机</a></div>
				<div><a rel="nofollow" target="_blank" href="#">延保服务</a></div>
				<div><a rel="nofollow" target="_blank" href="#">京东E卡</a></div>	
				<div><a rel="nofollow" target="_blank" href="#">京东通信</a></div>
				<div><a rel="nofollow" target="_blank" href="#">京东JD+</a></div>
			</dd>
		</dl>
		<div id="coverage">
			<div class="dt">
				京东自营覆盖区县
			</div>
			<div class="dd">
				<p>京东已向全国2423个区县提供自营配送服务，支持货到付款、POS机刷卡和售后上门服务。</p>
				<p class="ar"><a target="_blank" href="http://help.jd.com/user/issue/103-983.html">查看详情&nbsp;&gt;</a></p>
			</div>
		</div>
		<span class="clr"></span>
	</div>
</div>        <div class="w">
	<div id="footer-2014" >
		<div class="links">
			<a rel="nofollow" target="_blank" href="#">关于我们</a>|<a  href="#">联系我们</a>|<a rel="nofollow" target="_blank" href="#">商家入驻</a>|<a rel="nofollow" target="_blank" href="#">营销中心</a>|<a rel="nofollow" target="_blank" href="#">手机京东</a>|<a target="_blank" href="#">友情链接</a>|<a target="_blank" href="#">销售联盟</a>|<a href="#" target="_blank">京东社区</a>|<a href="#" target="_blank">京东公益</a>|<a href="#" target="_blank">English Site</a>|<a href="#" target="_blank">Contact Us</a></div>
		<div class="copyright">
			<a target="_blank" href="#"><img src="../../images/56a0a994Nf1b662dc.png"> 京公网安备 11000002000088号</a>&nbsp;&nbsp;|&nbsp;&nbsp;京ICP证070359号&nbsp;&nbsp;|&nbsp;&nbsp;<a target="_blank" href="#">互联网药品信息服务资格证编号(京)-经营性-2014-0008</a>&nbsp;&nbsp;|&nbsp;&nbsp;新出发京零&nbsp;字第大120007号<br><a rel="nofollow" href="#" target="_blank">音像制品经营许可证苏宿批005号</a>&nbsp;&nbsp;|&nbsp;&nbsp;出版物经营许可证编号新出发(苏)批字第N-012号&nbsp;&nbsp;|&nbsp;&nbsp;互联网出版许可证编号新出网证(京)字150号<br><a href="#" target="_blank">网络文化经营许可证京网文[2014]2148-348号</a>&nbsp;&nbsp;违法和不良信息举报电话：4006561155&nbsp;&nbsp;Copyright&nbsp;©&nbsp;2004-2016&nbsp;&nbsp;京东JD.com&nbsp;版权所有<br>京东旗下网站：<a target="_blank" href="http://www.360top.com/">360TOP</a>&nbsp;&nbsp;<a href="#" target="_blank">拍拍网</a>&nbsp;&nbsp;<a href="#" target="_blank">网银在线</a></div>
		
	  </div>
    </div>
  </div>
</body>
<script type="text/javascript">
	var shopId = ${goods.shopId};
	var goodsId = ${goods.goodsId};
	queryShop();
	function queryShop(){
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/detailQueryShop",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				shopId:shopId
				},
			success:function(data){
				var str = "<table border='0' align='center' style='width:100%; margin:10px auto;' cellspacing='0' cellpadding='0'>";
				str += "<tr><td>商户名称："+data[0].shopName+"</td><td>商户地址："+data[0].shopAddress+"</td></tr>";
                str += "<tr><td>商户电话："+data[0].shopTel+"</td><td>商户邮箱："+data[0].shopEmail+"</td></tr></table>";
				$("#showShop").html(str);
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}
	queryEval();
	function queryEval(){
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/detailQueryEval",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				goodsId:goodsId
				},
			success:function(data){
				var str = "";
				var score = "";
				for(var i = 0;i<data.length;i++){
					if(data[i].evalLeval>5){
						score = "好评";
					}else if(data[i].evalLeval>3){
						score = "中评";
					}else{
						score = "差评";
					}
					str += "<tr valign='top'><td width='160'>"+data[i].userName+"</td><td width='180'>"+score+"</td>";
                    str += "<td>"+data[i].evalContent+"<br/><font color='#999999'>"+data[i].evalTime+"</font></td></tr>";
				}
				$("#showEval").html(str);
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}	
	function inrs(){
		var input = parseInt(document.getElementById("count").value)+1;
		$("#count").val(input);
	}
	function ders(){
		var input = parseInt(document.getElementById("count").value);
		if(input == 1){
			input = 1;
		}else{
			input = input - 1;
		}
		$("#count").val(input);
	}
	function favorite(goodsId,userId){
		alert(userId);
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/addFavorite",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				goodsId:goodsId,
				userId:userId
				},
			success:function(data){
				if(data == 1){
					alert("加入收藏夹成功");
				}else{
					alert("该商品已经加入收藏夹");
				}
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}
	function addCart(goodsId,userId){
		var cartNum = parseInt(document.getElementById("count").value);
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/addCart",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				goodsId:goodsId,
				userId:userId,
				cartNum:cartNum
				},
			success:function(data){
				if(data == 1){
					alert("加入购物车成功");
				}else{
					alert("该商品已经加入购物车");
				}
			},
			error:function(err){
				alert("操作失败");
			}
		});
	}
	function goOrder(goodsId,userId){
		var cartNum = parseInt(document.getElementById("count").value);
		window.location.href="${pageContext.request.contextPath}/addOrder?goodsId="+goodsId+"&userId="+userId+"&cartNum="+cartNum;
	}
</script>
</html>